﻿using System.ComponentModel.Composition;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Utilities;
using Microsoft.VisualStudio.Text.Tagging;
using Microsoft.VisualStudio.Text.Classification;
using Microsoft.VisualStudio.Text.Outlining;
using Microsoft.VisualStudio.Text.Projection;

namespace FunctionPointScrollMargin
{
    #region FunctionPointScrollMargin Factory
    /// <summary>
    /// Export a <see cref="IWpfTextViewMarginProvider"/>, which returns an instance of the margin for the editor
    /// to use.
    /// </summary>
    [Export(typeof(IWpfTextViewMarginProvider))]
    [Name(PredefinedFunctionPointMarginNames.FunctionPointChangeTracking)]
    [Order(After = PredefinedMarginNames.VerticalScrollBar)] //Ensure that the margin occurs below the horizontal scrollbar
    [MarginContainer(PredefinedMarginNames.VerticalScrollBarContainer)] 
    [ContentType("text")] //Show this margin for all text-based types
    [TextViewRole(PredefinedTextViewRoles.Document)]
    internal sealed class FunctionPointScrollMarginProvider : IWpfTextViewMarginProvider
    {

        [Import]
        internal IViewTagAggregatorFactoryService TagAggregatorFactoryService { get; private set; }

        [Import]
        internal IEditorFormatMapService EditorFormatMapService { get; private set; }

        [Import]
        internal IScrollMapFactoryService ScrollMapFactory { get; private set; }

        [Import]
        internal IOutliningManagerService OutliningManagerService { get; private set; }

        [Import]
        internal ITextEditorFactoryService TextEditorFactoryService { get; private set; }

        [Import]
        internal IProjectionBufferFactoryService ProjectionBufferFactoryService { get; private set; }



        //[Import(AllowDefault = true)]
        //internal ISettingsStore _settingsStore { get; set; }

        public IWpfTextViewMargin CreateMargin(IWpfTextViewHost textViewHost, IWpfTextViewMargin containerMargin)
        {
            //var parentMargin = containerMargin as ;

            return new FunctionPointScrollMargin(textViewHost, containerMargin, this  );
        }
    }
    #endregion
}
